<template>
    <router-view></router-view>
</template>

<script>
import {mapState, mapMutations} from 'vuex'

export default {
    name: 'App',
    computed: {
        ...mapState(['theme'])
    },
    created() {
        console.log(this.theme)
        // 判断是否选择过主题，为选择过默认彩色主题
        if (!this.theme) {
            document.getElementById('app').setAttribute('class', 'theme-1');
            this.setState({theme: 'theme-1'})
            localStorage.setItem("theme", "theme-1");
            this.setState({buttonColor: '#f56c6c'})
            localStorage.setItem("buttonColor", "#f56c6c");
        } else {
            document.getElementById('app').setAttribute('class', this.theme);
        }
    },
    methods: {
        ...mapMutations(['setState'])
    }
}
</script>
<style>
body {
    margin: 0;
}

</style>
